package cn.edu.nuc.onlinestore.frame;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

public class IndexFrame extends JFrame {

	private static final long serialVersionUID = 6474835847037590589L;

	private JPanel contentPane;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					IndexFrame frame = new IndexFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public IndexFrame() {
		setTitle("购物系统首页");
		setIconImage(Toolkit.getDefaultToolkit().getImage("image/gouwu.png"));
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 460, 376);
		setLocation(200, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		// 背景图片
		Icon icon = new ImageIcon("image/bg.jpg");
		JLabel jl = new JLabel(icon);
		jl.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
		getLayeredPane().add(jl, new Integer(Integer.MIN_VALUE));
		contentPane.setOpaque(false);
		contentPane.setLayout(null);

		textField = new JTextField();
		textField.setHorizontalAlignment(SwingConstants.CENTER);
		textField.setEditable(false);
		textField.setForeground(Color.RED);
		textField.setText("欢迎进入购物系统");
		textField.setBounds(123, 32, 197, 34);
		contentPane.add(textField);
		textField.setColumns(10);

		JButton button = new JButton("管理员登录");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				AdminLogin ad = new AdminLogin();
				ad.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
				ad.setVisible(true);
			}
		});
		button.setBounds(172, 100, 103, 23);
		contentPane.add(button);

		JButton button_1 = new JButton("用户登录");
		button_1.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				UserLogin user = new UserLogin();
				user.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
				user.setVisible(true);
			}
		});
		button_1.setBounds(172, 150, 103, 23);
		contentPane.add(button_1);

		JButton button2 = new JButton("退出系统");
		button2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button2.setBounds(172, 201, 103, 23);
		contentPane.add(button2);
	}
}
